home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / intuition / closewindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  2.7 KB  |  118 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: closewindow.c,v 1.2 1996/08/29 13:33:30 digulla Exp $
  4.     $Log: closewindow.c,v $
  5.     Revision 1.2  1996/08/29 13:33:30  digulla
  6.     Moved common code from driver to Intuition
  7.     More docs
  8.  
  9.     Revision 1.1  1996/08/13 15:37:26  digulla
  10.     First function for intuition.library
  11.  
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include "intuition_intern.h"
  17. #include <clib/exec_protos.h>
  18. #include <clib/graphics_protos.h>
  19.  
  20. extern void intui_CloseWindow (struct Window *, struct IntuitionBase *);
  21. extern int  intui_GetWindowSize (void);
  22.  
  23. /*****************************************************************************
  24.  
  25.     NAME */
  26.     #include <clib/intuition_protos.h>
  27.  
  28.     __AROS_LH1(void, CloseWindow,
  29.  
  30. /*  SYNOPSIS */
  31.     __AROS_LHA(struct Window *, window, A0),
  32.  
  33. /*  LOCATION */
  34.     struct IntuitionBase *, IntuitionBase, 12, Intuition)
  35.  
  36. /*  FUNCTION
  37.     Closes a window. Depending on the display, this might not happen
  38.     at the time when this function returns, but you must not use
  39.     the window pointer after this function has been called.
  40.  
  41.     INPUTS
  42.     window - The window to close
  43.  
  44.     RESULT
  45.     None.
  46.  
  47.     NOTES
  48.     The window might not have been disappeared when this function returns.
  49.  
  50.     EXAMPLE
  51.  
  52.     BUGS
  53.  
  54.     SEE ALSO
  55.     OpenWindow(), OpenWindowTags()
  56.  
  57.     INTERNALS
  58.  
  59.     HISTORY
  60.     29-10-95    digulla automatically created from
  61.                 intuition_lib.fd and clib/intuition_protos.h
  62.  
  63. *****************************************************************************/
  64. {
  65.     __AROS_FUNC_INIT
  66.     __AROS_BASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  67.     struct IntuiMessage * im;
  68.  
  69.     IntuitionBase->ActiveWindow = NULL;
  70.  
  71.     /* Remove window from the chain and find next active window */
  72.     if (window->Descendant)
  73.     {
  74.     window->Descendant->Parent = window->Parent;
  75.     IntuitionBase->ActiveWindow = window->Descendant;
  76.     }
  77.     if (window->Parent)
  78.     {
  79.     window->Parent->NextWindow =
  80.         window->Parent->Descendant =
  81.         window->Descendant;
  82.  
  83.     if (!IntuitionBase->ActiveWindow)
  84.         IntuitionBase->ActiveWindow = window->Parent;
  85.     }
  86.  
  87.     /* Make sure the Screen is still valid */
  88.     if (window == window->WScreen->FirstWindow)
  89.     window->WScreen->FirstWindow = window->NextWindow;
  90.  
  91.     /* Let the driver clean up */
  92.     intui_CloseWindow (window, IntuitionBase);
  93.  
  94.     /* Free resources */
  95.     CloseFont (window->RPort->Font);
  96.  
  97.     FreeMem (window->RPort, sizeof (struct RastPort));
  98.  
  99.     if (window->UserPort)
  100.     {
  101.     /* Delete all pending messages */
  102.     Forbid ();
  103.  
  104.     while ((im = (struct IntuiMessage *) GetMsg (window->UserPort)))
  105.         ReplyMsg ((struct Message *)im);
  106.  
  107.     Permit ();
  108.  
  109.     /* Delete message port */
  110.     DeleteMsgPort (window->UserPort);
  111.     }
  112.  
  113.     /* Free memory for the window */
  114.     FreeMem (window, intui_GetWindowSize ());
  115.  
  116.     __AROS_FUNC_EXIT
  117. } /* CloseWindow */
  118.